<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
				 java.util.ArrayList,
				 com.scalar.chiptrack.alarms.Alarm,
				 com.scalar.chiptrack.sales.Quotation,
				 com.scalar.chiptrack.utils.StringUtils,
				 com.scalar.chiptrack.alarms.AlarmUser,
				 com.scalar.chiptrack.alarms.Comment,
				 java.util.Iterator,
				 com.scalar.chiptrack.sales.LineItem"%>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
		<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
		<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
		<TD valign="top" width="100%">
			<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border="0">
			<BR>
			<IMG src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" width=180 height=72 border="0">
			<center>
				<span class="NArialW">Notification Information</span>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<font class='NArialL'>
					[<a href="javascript:window.close();" onMouseOver="window.status='Close this window';return true">Close</a>]
				</font>
			</center>
			<table border='0' width='80%' align='center'>
				<tr><td><chiptrack:errors styleClass="NArialL" /></td></tr>
				<tr>
					<td colspan='2' bgcolor='#993333' align='center'>
						<font color='#FFFFFF'><font size='4'><strong>Notification Details</strong></font></font>
					</td>
				</tr>
				<tr bgcolor='#DEE1E2'  class="NArialL">
					<td>Notification Name:</td>
					<td>
					<%
						boolean quotation_status = false;
						Alarm alarm =(Alarm) request.getAttribute("alarm");
					%>
					<%=alarm.getName()%>
					</td>
				</tr>
				<tr bgcolor='#FFFFFF'  class="NArialL">
					<td>Notification Type:</td>
					<td><%=alarm.getType()%></td>
				</tr>
				<tr bgcolor='#DEE1E2' class="NArialL">
					<td>Created By:</td>
					<td><%=alarm.getOriginator().getName()%></td>
				</tr>
				<tr bgcolor='#FFFFFF' class="NArialL">
					<td>Created On:</td>
					<td>
					<%=StringUtils.formatDateToString(new java.util.Date (alarm.getCreatedOn()))%>
					</td>
				</tr>
				<tr bgcolor='#DEE1E2' class="NArialL">
					<td>Expires On:</td>
					<%
						if (alarm.getExpiresOn() == -1)
						{
					%>
					<td>Never Expires</td></tr>
					<%
						}
						else
						{
					%>
					<td><%=StringUtils.formatDateToString(new java.util.Date (alarm.getExpiresOn()))%></td>
				</tr>
					<%
					   }
					%>
				<tr bgcolor='#FFFFFF'  class="NArialL">
					<td>Priority:</td>
					<td><%=alarm.getPriority()%></td>
				</tr>
				<tr bgcolor='#DEE1E2' class="NArialL">
					<td>Notification Current State:</td>
					<td><%=alarm.getCurrentState()%></td>
				</tr>
				<tr bgcolor='#FFFFFF' class="NArialL">
					<td>Last Updated By:</td>
					<td><%=alarm.getLastUpdatedBy()%></td>
				</tr>
				<%
					String bgColor[] = { "#DEE1E2", "#FFFFFF"};
					int i = 0;
					Iterator it = alarm.getRecipients();
				%>

				<tr><td colspan='2'><br></td></tr>
				<tr>
					<td colspan='2' bgcolor='#993333' align='left'><font class="NArialL"><font color='#FFFFFF'>Responses:</font></font></td>
				</tr>
				<%
					while( it.hasNext() )
					{
				%>
				<tr bgcolor="<%=bgColor[i%2]%>">
					<td  class="NArialL">
				<%
					AlarmUser au = ( AlarmUser )it.next();
				%>
					<%=au.getName()%>:
					</td>
					<td  class="NArialL"><%=au.getResponse()%></td>
				</tr>
				<%
					i++;
					}
				%>
				<%
					String commentString = null;
					if ( ( alarm.getComments() != null ) && ( alarm.getComments().size() > 0 ) )
					{
				%>
				<tr><td colspan='2'><br></td></tr>
				<%
					Comment comment = null;
					int size = alarm.getComments().size();
				%>
				<tr>
					<td colspan='2'>
						<table border='0' width='100%' align='center'>
							<tr>
								<td colspan='3' bgcolor='#993333' align='left'><font class="NArialL"><font color='#FFFFFF'>Comments:</font></font></td>
							</tr>
							<%
								int color= 0;
								for (int x=0; x<size; x++)
								{
									comment = ( Comment ) alarm.getComments().get( x );
									commentString = comment.getComment();
									if ( ( commentString != null ) && ( commentString.trim().length() != 0 ) )
									{
							%>
							<tr bgcolor="<%=bgColor[color%2]%>">
								<td width='15%'  class="NArialL"><%=comment.getCreatedBy()%> </td>
								<td width='25%'  class="NArialL"><%=StringUtils.formatDateToString(new java.util.Date (comment.getCreatedOn()))%></td>
								<td width='60%' class="NArialL"><%=comment.getComment()%></td>
							</tr>

							<%
									color++;
									}
								}
							%>
						</table>
					</td>
				</tr>
				<%
					}
				%>
				<%
					Quotation quotation = (Quotation)request.getAttribute("quotation");

				%>
				<%
					if( quotation != null )
					{
				%>
				<tr><td colspan='2'><br></td></tr>
				<tr>
					<td colspan='2' bgcolor='#993333' align='center'><font  color='#FFFFFF' size='4'>
						<strong>Quote Details</strong></font>
					</td>
				</tr>
				<tr>
					<td colspan='2'>
						<table>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Created By:</td>
								<td class="NArialL" width='20%'><%=alarm.getOriginator().getName()%></td>
								<td width='30%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Last Updated On:</td>
								<td class="NArialL" width='20%'><%=StringUtils.formatDateToString(new java.util.Date (alarm.getCreatedOn()))%></td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Quote No:</td>
								<td class="NArialL" width='20%'><%=quotation.getQuotationNo()%></td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Customer Name:</td>
								<td class="NArialL" width='20%'><%=quotation.getCustomerName()%></td>
							</tr>
							<tr>
								<td bgcolor='#DEE1E2' class="NArialL" width="25%"><font class="NArialL">Quote Revision :</font></td>
								<td width="20%" class="NArialL"><%=quotation.getRevision()%></td>
								<td width='10%'>&nbsp;</td>
								<td width='25%' bgcolor='#DEE1E2' class="NArialL">&nbsp;</td>
								<td width='20%'>&nbsp;</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesOrder.PoRevisionNumber"/>:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getPoRev() != null ) { %>
										<%=quotation.getPoRev()%>
									<% } %>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesOrder.PoDate"/>:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getPoDate() != null ) { %>
										<%=quotation.getPoDate() %>
									<% } %>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesOrder.PoNumber"/>:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getCustomerPO() != null ) { %>
									<%=quotation.getCustomerPO()%>
									<% } %>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Contact Person:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getContactPerson() != null ) { %>
									<%=quotation.getContactPerson()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Phone:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getPhoneNumber() != null ) { %>
									<%=quotation.getPhoneNumber()%>
									<% } %>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Cell:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getCellNumber() != null ) { %>
									<%=quotation.getCellNumber()%>
									<% } %>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Fax:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getFaxNumber() != null ) { %>
									<%=quotation.getFaxNumber()%>
									<% } %>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Email:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getEmail() != null ) { %>
									<%=quotation.getEmail()%>
									<% } %>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Sales Person:</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getSalesPerson() != null ) { %>
									<%=quotation.getSalesPerson()%>
									<% } %>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesRep.Name"/> :</td>
								<td class="NArialL" width='20%'>
									<% if( quotation.getSalesRep() != null ) { %>
									<%=quotation.getSalesRep()%>
									<% } %>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Regional Rep:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getRegionalRep() != null){%>
									<%=quotation.getRegionalRep()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Quote Date:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getQuotationDate() != null){%>
									<%=quotation.getQuotationDate()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td bgcolor='#DEE1E2' class="NArialL" width="25%"><font class="NArialL"><bean:message key="label.sales.endUser"/>:</font></td>
								<td width="20%" class="NArialL">
									<% if(quotation.getEndCustomer() != null){%>
										<%=quotation.getEndCustomer()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td width='25%' bgcolor='#DEE1E2' class="NArialL"><bean:message key="label.sales.endCustomer"/></td>
								<td width='20%' class="NArialL">
									<% if(quotation.getOdm() != null){%>
										<%=quotation.getOdm()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesOrder.ShippingMethod" />:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getShippingMethod() != null){%>
									<%=quotation.getShippingMethod()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>&nbsp;</td>
								<td class="NArialL" width='20%'>&nbsp;</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Pay Terms :</td>
								<td class="NArialL" width='20%'><% if(quotation.getShippingTerms() != null){%>
									<%=quotation.getShippingTerms()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'><bean:message key="label.sales.salesOrder.DeliveryTerms" /> :</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getDeliveryTerms()!= null){%>
									<%=quotation.getDeliveryTerms()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td bgcolor='#DEE1E2' class="NArialL" width='25%'>Billing Address:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getBillingAddress() != null){%>
									<%=quotation.getBillingAddressAsHTML()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Shipping Address:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getShippingAddress() != null){%>
									<%=quotation.getShippingAddressAsHTML()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Freight Instructions :</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getFreightInstructions()!= null){%>
									<%=quotation.getFreightInstructions()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Shipping Instructions:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getShippingInstructions() != null){%>
									<%=quotation.getShippingInstructions()%>
									<%}%>
								</td>
							</tr>
							<tr>
								<td bgcolor='#DEE1E2' class="NArialL" width='25%'>Quotation Expires On :</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getExpiryDate() != null){%>
									<%=quotation.getExpiryDate()%>
									<%}%>
								</td>
								<td width='10%'>&nbsp;</td>
								<td  bgcolor='#DEE1E2' class="NArialL" width='25%'>Comments:</td>
								<td class="NArialL" width='20%'>
									<% if(quotation.getComments() != null){%>
									<%=quotation.getComments()%>
									<%}%>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<%
					ArrayList presentList = ( ArrayList ) request.getAttribute("presentList");
					if( presentList != null &&  presentList.size() > 0 )
                    {
				%>
                <tr><td colspan='2'><br></td></tr>
                <tr><td colspan='2' class="NArialW"><font size='4'>Present LineItems</font></td></tr>
                <tr>
                    <td colspan='2'>
                        <table border='0' width='100%' bordercolor='#FFFFFF'>
                            <tr>
                                <td width='9%' align=left bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>PO Line Item</font></font>
                                </td>
                                <td width='9%' align=left bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Line Item</font></font>
                                </td>
                                <td width='15%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'><bean:message key="label.mfgPartNumber" /></font></font>
                                </td>
                                <td width='10%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'><bean:message key="label.customerPartNumber"/></font></font>
                                </td>
                                <td width='10%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Description</font></font>
                                </td>
                                <td width='5%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Taxable</font></font>
                                </td>
                                <td width='8%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Reqd Dock Date</font></font>
                                </td>
                                <td width='5%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Quantity</font></font>
                                </td>
                                <td width='8%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Lead Time</font></font>
                                </td>
                                <td width='8%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Price </font></font>
                                </td>
                                <td width='8%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Amount</font></font>
                                </td>
                                <td width='8%' align=center bgcolor='#993333'>
                                    <font class="NArialL"><font color='#FFFFFF'>Hold</font></font>
                                </td>
                            </tr>
                            <%
                                for( int p = 0; p < presentList.size(); p++ )
                                {
                                    LineItem lineitem2 = ( LineItem ) presentList.get( p );
                            %>
                            <tr>
                                <td width='10%' bgcolor='#DEE1E2' align=center class="NArialL">
                                    <%=lineitem2.getPoLineItemNo()%>
                                </td>
                                <td width='10%' bgcolor='#DEE1E2' align=center class="NArialL">
                                    <%=lineitem2.getLineItemNo()%>
                                </td>
                                <td width='15%' bgcolor='#DEE1E2' class="NArialL">
                                <%
                                    if( lineitem2.getManufacturingPartNo() != null && !lineitem2.getManufacturingPartNo().equals( "null" ) )
                                    {
                                %>
                                       <%=lineitem2.getManufacturingPartNo()%></td>
                                <%
                                    }
                                    else
                                    {
                                %>
                                </td>
                                <%  } %>
                                <td width='10%' bgcolor='#DEE1E2'  align=center class="NArialL">
                                    <%=lineitem2.getCustomerPartNo()%>
                                </td>
                                <td width='10%' bgcolor='#DEE1E2' class="NArialL">
                                <%
                                   if( lineitem2.getLineItemDescription() != null ) {
                                %>
                                       <%=lineitem2.getLineItemDescription()%>
                                </td>
                                <%
                                }
                                else
                                {
                                %>
                               </td>
                                <% } %>
                                <td width='5%' bgcolor='#DEE1E2'  align=center class="NArialL">
                                    <%=lineitem2.getIsTaxableAsString()%>
                                </td>
                                <td width='8%' bgcolor='#DEE1E2' class="NArialL">
                                    <%=lineitem2.getRequestDate()%>
                                </td>
                                <td width='5%' bgcolor='#DEE1E2' align=right class="NArialL">
                                    <%=lineitem2.getQtyAsString()%>
                                </td>
                                <td width='5%' bgcolor='#DEE1E2' align=right class="NArialL">
                                    <%=lineitem2.getLeadTime()%>
                                </td>
                                <td width='8%' bgcolor='#DEE1E2' align=right class="NArialL">
                                    <%=lineitem2.getUnitPriceAsString()%>
                                </td>
                                <td width='8%' bgcolor='#DEE1E2' align=right class="NArialL">
                                    <%=lineitem2.getAmountAsString()%>
                                </td>
                                <td width='8%' bgcolor='#DEE1E2' align=center class="NArialL">
                                    <%=lineitem2.getIsApproved() ? "[]":"[X]"%>
                                </td>
                            </tr>
                            <%
                                    if( lineitem2.getIsApproved() == false  )
                                    {
                                        quotation_status = true;
                                    }
                                }
                            %>
                            <tr><td colspan="12">&nbsp</td></tr>
                            <tr>
                                <td colspan="9" align='center'>&nbsp;</td>
                                <td align='right' class="NArialL" nowrap>Sub Total</td>
                                <td bgcolor='#DEE1E2'  align='right' class="NArialL"><%=quotation.getSubTotalAsString()%></td>
                                <td align='center'>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="10" align=right class="NArialL" >Sales Tax</td>
                                <td bgcolor='#DEE1E2'  align='right' class="NArialL"><%=quotation.getSalesTaxAsString()%></td>
                                <td align='center'>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="10"align=right class="NArialL" >Freight</td>
                                <td bgcolor='#DEE1E2'  align='right' class="NArialL"><%=quotation.getFrieghtAsString()%></td>
                                <td align='center'>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="10" align=right class="NArialL" >
                                   <%=quotation.getMiscName() %>
                                </td>
                                <td bgcolor='#DEE1E2'  align='right' class="NArialL"><%=quotation.getMiscAsString()%></td>
                                <td align='center'>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="10" align=right  class="NArialL">Order Total</td>
                                <td bgcolor='#DEE1E2'  align='right' class="NArialL"><%=quotation.getOrderTotalAsString()%></td>
                                <td align='center'>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <%  }   %>
	            <%  }   %>
                <tr><td colspan='2'><br></td></tr>
                <%
                    String str = chipTracContext+"/approveQuotation.do?quotationId="+quotation.getQuotationId()+"&quotation=0&isSample=1";
                    if ( quotation_status == true  && !"Expired".equalsIgnoreCase( quotation.getStatus() ) )
                    {
                %>
                <tr bgcolor='#DEE1E2'>
                    <td colspan='2' class="NArialL">
                        Message from Originator: <br>Please Click <a href='<%=str%>'>here</a> to Approve<%--/Reject--%> this quote
                <% } %>
		            </td>
                </tr>
            </table>
        </TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
<script language="javascript">
function windowOpen()
{
    var str = '<%=str%>'
    var newWindow
	newWindow = window.open (str,'optionsPopup1','directories=yes,toolbar=yes,menubar=yes,personalbar=no,location=yes,status=yes,scrollbars=yes,resizable=yes');
	newWindow.focus();
}
</script>

</body>
</html>